#!/bin/bash

echo "[sentinel] Waiting for redis-master to be resolvable..."
while ! getent hosts redis-master > /dev/null; do
  sleep 1
done

echo "[sentinel] Waiting for redis-master to respond to PING..."
until redis-cli -h redis-master -p 6379 ping | grep -q PONG; do
  sleep 1
done

echo "[sentinel] redis-master is ready, starting redis-sentinel..."
exec "$@"